{% set pypi_name = 'pbr' %}
{% set upstream_version = upstream_version('5.5.1') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Python Build Reasonableness
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://opendev.org/openstack/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('setuptools') }}
BuildArch:      noarch

%description
PBR is a library that injects some useful and sensible default behaviors into
your setuptools run. It started off life as the chunks of code that were copied
between all of the OpenStack projects. Around the time that OpenStack hit 18
different projects each with at least 3 active branches, it seems like a good
time to make that code into a proper re-usable library.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Python Build Reasonableness
Requires:       {{ py3('setuptools') }}
%if 0%{?suse_version} > 1500
Obsoletes:       python-pbr < %{version}-%{release}
Obsoletes:       python2-pbr < %{version}-%{release}
%endif

%description -n {{ py2name(py_versions='py3') }}
PBR is a library that injects some useful and sensible default behaviors into
your setuptools run. It started off life as the chunks of code that were copied
between all of the OpenStack projects. Around the time that OpenStack hit 18
different projects each with at least 3 active branches, it seems like a good
time to make that code into a proper re-usable library.

%package -n python-pbr-doc
Summary:        Documentation for the PBR
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-pbr-doc
Documentation for the PBR, a library that injects some useful and sensible default
behaviors into your setuptools run.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
export SKIP_PIP_INSTALL=1
%py3_build

# generate html docs
PYTHONPATH=$PWD PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%py3_install

%files -n {{ py2name(py_versions='py3') }}
%{_bindir}/pbr
%doc README.rst
%license LICENSE
%{python3_sitelib}/{{ pypi_name }}
%{python3_sitelib}/{{ pypi_name }}-*-py?.?.egg-info

%files -n python-pbr-doc
%license LICENSE
%doc doc/build/html

%changelog
